package com.example.mymatch.controller;

import com.example.mymatch.model.Condition;

import com.example.mymatch.service.IConditionService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "党员缴费")
@RestController
public class ConditionController {
    @Autowired
    private IConditionService conditionService;//对某个业务服务的内容进行定义规范  编写者：谢楷诗
    @ApiOperation(value = "查询所有缴费信息",notes = "获取缴费信息返回json字符串")
    @RequestMapping("/getStr23")
    public String getCondition(){return "My condition";}
    @CrossOrigin
    @ApiOperation(value = "对缴费信息的添加方法")
    @GetMapping("/addCondition")
    public int addCondition(Condition condition){
        System.out.println("进入添加缴费信息接口");
        return conditionService.insertCondition(condition);
    }

    @GetMapping("getAll23")
    @ApiOperation(value = "对缴费信息查询方法")
    public List<Condition> getAllCondition(Condition condition){
        System.out.println("进入查询方法");
        List<Condition> listCondition=conditionService.getAllCondition(condition);
        return listCondition;
    }
    @PutMapping("/editCondition")
    @ApiOperation(value = "对缴费信息的修改方法")
    public int EditCondition(@RequestBody Condition condition){
        System.out.println("进入缴费修改方法");
        return conditionService.updateCondition(condition);
    }
    @GetMapping("/delCondition")
    @ApiOperation(value = "对缴费信息的删除方法")
    public int Delete(int id){
        System.out.println("进入缴费删除方法");
        int returnValue=0;
        if (id!=0){
            Condition condition=new Condition();
            condition.setConId(id);
            returnValue= conditionService.deleteCondition(condition);
        }
        return returnValue;
    }
    @GetMapping("/getOne23")
    @ApiOperation(value = "对单条缴费信息的查询方法")
    public Condition getCondition(int id){
        Condition condition=new Condition();
        System.out.println("进入单条查询方法");
        if (id!=0){
            Condition condition1=new Condition();
            condition1.setConId(id);
            condition=conditionService.getCondition(condition1);
            System.out.println("返回的数据集合为："+condition.getPmDangid());
        }
        return condition;
    }
}
